home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SAMPLES / VISDATA / JOIN.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-07  |  5.1 KB  |  166 lines

  1. VERSION 5.00
  2. Begin VB.Form frmJoin 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Join Tables"
  5.    ClientHeight    =   2025
  6.    ClientLeft      =   1125
  7.    ClientTop       =   1560
  8.    ClientWidth     =   5910
  9.    HelpContextID   =   2016131
  10.    Icon            =   "JOIN.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   2025
  16.    ScaleWidth      =   5910
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   1  'CenterOwner
  19.    Begin VB.CommandButton cmdClearJoins 
  20.       Caption         =   "C&lear All Joins"
  21.       Height          =   372
  22.       Left            =   2040
  23.       MaskColor       =   &H00000000&
  24.       TabIndex        =   7
  25.       Top             =   1560
  26.       Width           =   1812
  27.    End
  28.    Begin VB.CommandButton cmdClose 
  29.       Cancel          =   -1  'True
  30.       Caption         =   "&Close"
  31.       Height          =   372
  32.       Left            =   3960
  33.       MaskColor       =   &H00000000&
  34.       TabIndex        =   6
  35.       Top             =   1560
  36.       Width           =   1812
  37.    End
  38.    Begin VB.ListBox lstFields2 
  39.       BackColor       =   &H00FFFFFF&
  40.       Height          =   1035
  41.       Left            =   3960
  42.       TabIndex        =   4
  43.       Top             =   300
  44.       Width           =   1815
  45.    End
  46.    Begin VB.ListBox lstFields1 
  47.       BackColor       =   &H00FFFFFF&
  48.       Height          =   1035
  49.       Left            =   2040
  50.       TabIndex        =   3
  51.       Top             =   300
  52.       Width           =   1815
  53.    End
  54.    Begin VB.CommandButton cmdAddJoin 
  55.       Caption         =   "&Add Join to Query"
  56.       Enabled         =   0   'False
  57.       Height          =   372
  58.       Left            =   120
  59.       MaskColor       =   &H00000000&
  60.       TabIndex        =   1
  61.       Top             =   1560
  62.       Width           =   1812
  63.    End
  64.    Begin VB.ListBox lstTables 
  65.       BackColor       =   &H00FFFFFF&
  66.       Height          =   1035
  67.       Left            =   120
  68.       MultiSelect     =   1  'Simple
  69.       TabIndex        =   0
  70.       Top             =   300
  71.       Width           =   1815
  72.    End
  73.    Begin VB.Label lblLabels 
  74.       Alignment       =   2  'Center
  75.       Caption         =   "Select Fields to Join on: "
  76.       Height          =   195
  77.       Index           =   1
  78.       Left            =   2040
  79.       TabIndex        =   5
  80.       Top             =   45
  81.       Width           =   3735
  82.    End
  83.    Begin VB.Label lblLabels 
  84.       AutoSize        =   -1  'True
  85.       Caption         =   "Select Table Pair: "
  86.       Height          =   195
  87.       Index           =   0
  88.       Left            =   120
  89.       TabIndex        =   2
  90.       Top             =   45
  91.       Width           =   1290
  92.    End
  93. Attribute VB_Name = "frmJoin"
  94. Attribute VB_GlobalNameSpace = False
  95. Attribute VB_Creatable = False
  96. Attribute VB_PredeclaredId = True
  97. Attribute VB_Exposed = False
  98. Option Explicit
  99. '>>>>>>>>>>>>>>>>>>>>>>>>
  100. Const FORMCAPTION = "Join Tables"
  101. Const Label1 = "Select Table Pair:"
  102. Const Label2 = "Select Fields to Join on:"
  103. Const BUTTON1 = "&Add Join to Query"
  104. Const BUTTON2 = "C&lear All Joins"
  105. Const BUTTON3 = "&Close"
  106. '>>>>>>>>>>>>>>>>>>>>>>>>
  107. Dim mtblTable1 As String
  108. Dim mtblTable2 As String
  109. Private Sub cmdAddJoin_Click()
  110.   Dim i As Integer
  111.   frmQuery.lstJoinFields.AddItem AddBrackets(mtblTable1) & "." & AddBrackets(lstFields1) & "=" & AddBrackets(mtblTable2) & "." & AddBrackets(lstFields2)
  112.   For i = 0 To lstTables.ListCount - 1
  113.     lstTables.Selected(i) = False
  114.   Next
  115. End Sub
  116. Private Sub lstFields1_Click()
  117.   cmdAddJoin.Enabled = Len(lstFields2.Text) > 0
  118. End Sub
  119. Private Sub lstFields2_Click()
  120.   cmdAddJoin.Enabled = Len(lstFields1.Text) > 0
  121. End Sub
  122. Private Sub cmdClearJoins_Click()
  123.   frmQuery.lstJoinFields.Clear
  124. End Sub
  125. Private Sub cmdClose_Click()
  126.   Unload Me
  127. End Sub
  128. Private Sub lstTables_Click()
  129.   Dim i As Integer
  130.   Dim tblTableDefObj As TableDef
  131.   Dim fld As Field
  132.   mtblTable1 = vbNullString
  133.   mtblTable2 = vbNullString
  134.   For i = 0 To lstTables.ListCount - 1
  135.     If lstTables.Selected(i) Then
  136.       If Len(mtblTable1) = 0 Then
  137.         mtblTable1 = lstTables.List(i)
  138.       Else
  139.         mtblTable2 = lstTables.List(i)
  140.         Exit For
  141.       End If
  142.     End If
  143.   Next
  144.   If Len(mtblTable2) = 0 Then Exit Sub   'only one table selected
  145.   Set tblTableDefObj = gdbCurrentDB.TableDefs(mtblTable1)
  146.   ListItemNames tblTableDefObj.Fields, lstFields1, True
  147.   Set tblTableDefObj = gdbCurrentDB.TableDefs(mtblTable2)
  148.   ListItemNames tblTableDefObj.Fields, lstFields2, True
  149. End Sub
  150. Private Sub Form_Load()
  151.   Dim i As Integer
  152.   Me.Caption = FORMCAPTION
  153.   lblLabels(0).Caption = Label1
  154.   lblLabels(1).Caption = Label2
  155.   cmdAddJoin.Caption = BUTTON1
  156.   cmdClearJoins.Caption = BUTTON2
  157.   cmdClose.Caption = BUTTON3
  158.   For i = 0 To frmQuery.lstTables.ListCount - 1
  159.     If frmQuery.lstTables.Selected(i) Then
  160.       lstTables.AddItem frmQuery.lstTables.List(i)
  161.     End If
  162.   Next
  163.   Me.Top = frmMDI.Top + frmQuery.Top + frmQuery.txtCriteria.Top + 1300
  164.   Me.Left = frmQuery.Left + 1500
  165. End Sub
  166.